//
//  ErrorMessageManager.m
//  siyanone
//
//  Created by LK-IOS on 2018/3/27.
//  Copyright © 2018年 LK-News. All rights reserved.
//

#import "ErrorMessageManager.h"

@implementation ErrorMessageManager

+ (BOOL)showErrorMessageWithError:(NSError *)error vc:(UIViewController *)vc
{
    // 无网络提示
    if (error.code == NSURLErrorNotConnectedToInternet){
        [[NavTipsView defaultTipsView] showTipsBannerInView:vc.view WithType:NavTipsViewTypeMessage text:kNet_Error_NotConnect isExistNav:YES];
        return YES;
    }
    //网络超时
    if (error.code == NSURLErrorTimedOut) {
        [[NavTipsView defaultTipsView] showTipsBannerInView:vc.view WithType:NavTipsViewTypeMessage text:kNet_Error_Timeout isExistNav:YES];
        return YES;
    }
    //网络异常
    
    if (error.code == NSURLErrorNetworkConnectionLost || error.code == NSURLErrorCancelled) {
        [[NavTipsView defaultTipsView] showTipsBannerInView:vc.view WithType:NavTipsViewTypeMessage text:kNet_Error_ConnectionLost isExistNav:YES];
        return YES;
    }
    //(AFNetworking返回的错误code小于0统一处理) 服务器繁忙
    if (error.code < 0) {
        [[NavTipsView defaultTipsView] showTipsBannerInView:vc.view WithType:NavTipsViewTypeMessage text:kNet_Error_ServerBusy isExistNav:YES];
        return YES;
    }
    return NO;
}

@end
